﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Sekretar.Repository;

namespace Sekretar
{
    public partial class ObrazovanjeRecView : Common.Forms.RecView
    {
        int zaposleniId, id;

        RStrucnaSprema rStrucnaSprema = new RStrucnaSprema();
        RZanimanje rZanimanje = new RZanimanje();
        RObrazovanje rObrazovanje = new RObrazovanje();

        public ObrazovanjeRecView(int zaposleniId, int id)
        {
            InitializeComponent();
            this.zaposleniId = zaposleniId;
            this.id = id;
        }

        #region Load
        private void ObrazovanjeRecView_Load(object sender, EventArgs e)
        {
            bsZanimanje.DataSource = rZanimanje.VratiSveAktivne();
            bsStrucnaSprema.DataSource = rStrucnaSprema.VratiSve();

            if (id == 0)
            {
                bsMaster.DataSource = rObrazovanje.Nov();
                ((DataLayer.Obrazovanje)bsMaster.Current).ZaposleniId = this.zaposleniId;
            }
            else
                bsMaster.DataSource = rObrazovanje.Izmeni(this.id);
        }
        #endregion

        #region OK
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Index = rObrazovanje.Snimi((DataLayer.Obrazovanje)bsMaster.Current);
            }
            catch (Exception ex)
            {
                Common.Tools.MessageError.Show(ex.Message);
                this.DialogResult = DialogResult.None;
            }
        }
        #endregion
    }
}
